﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Weblications.Sango.Protocol.player;
using Pixysoft.Weblications.Sango.Protocol;

namespace Pixysoft.Weblications.Sango.Command.world
{
    partial class SangoWorldHandler
    {
        public world_rvrlist world_rvrlist(long nationtypecode)
        {
            string usercode = SangoManager.Authentication();

            world_rvrlist response = ReflectionManager.CreatePojo<world_rvrlist>();

            Entities.Usr_Section section = UsrSectionDao.GetSection(usercode);
            Entities.Cti_Section citySection = CitySectionHelper.searchSectionByCode(section.Sectionserialcode);
            Entities.Sys_Section sysSection = SysSectionHelper.searchSectionByCode(section.Sectionserialcode);
            Entities.Sys_Sectionbattle sysBattle = SysSectionBattleHelper.searchByFight(citySection.Fightwincount);

            Entities.Sys_Sectionbattle sectionBattle = SysSectionBattleHelper.searchByFight(citySection.Fightwincount);
            List<Entities.Cti_Section> candidates = CitySectionHelper.searchSectionByGrade(nationtypecode, sectionBattle.Gradetypecode);
            List<Entities.Cti_Section> targets = SectionFormular.randomSections(candidates, citySection.Fightseedvalue, sectionBattle.Selectioncount);

            response.sections = UsrSectionFacade.ToSections(targets);
            response.preparetime = 0;//TODO
            response.fightcount = citySection.Fightwincount;
            response.totalfightcount = sysBattle.Fightwincount;
            response.Succeed = true;
            return response;
        }
    }

    public interface world_rvrlist : ISangoResponse
    {
        List<player_section> sections { get;set;}
        long preparetime { get;set;}
        long fightcount { get;set;}
        long totalfightcount { get;set;}
    }


}
